{% extends 'manage/manageBase.html' %}

{% block script %}
    {{ super() }}
    <script>
        //JavaScript代码区域
        layui.use(['form', 'laydate'], function () {
            var form = layui.form
                , laydate = layui.laydate;
            // 时间选择框
            laydate.render({
                elem: '#gettime' //指定元素
            });

            //表单初始赋值
            form.val('example', {
                "receive": "版本号: [ 2019xxxx ] \t\t\t安装目录: [ /opt/drs/ ] \n服务列表: [ccu, frame, command, compose," +
                    " db-convert, dataStorage,db-convert2, disposalSum, earlyWarning, earlyWarning2, " +
                    "communication]\n映射关系-----------------------外网地址: [ x.x.x.x ]\n内网端口: [  ] --> 外网端口: [  ] "
                , "mysql": "版本号: [ 2019xxxx ]\t\t库名: [  ] \nmysql版本: [ 5.6 ]\t\t\t端口号: [ 3306 ]\n本地用户: [ root ]  " +
                    "\t\t\t密码: [  ]\n用户名: [ gmonitor ]\t\t\t密码: [  ]\n安装目录: [  ]\t\t\t数据目录: [  ]"
                , "webe": "版本号: [ v6.2.xx ]\n安装路径: [ /usr/local/website/gmonitor ]\n内网地址: [  ]" +
                    "   --> 外网地址: [  ]"
                , "jdk": "1.8.151"
                , "tomcat": "8.0.53"
                , "redis": "4.0.11"
                , "zookeeper": "3.4.12"
                , "kakfa": "2.11-2.0.0"
            });
            //监听提交
            form.on('submit(demo1)', function (data) {
                $.ajax({
                    url: "{{ url_for('manage.gpApi') }}",
                    type: "post",
                    async: false,
                    dataType: 'json',
                    contentType: 'application/json',
                    data: JSON.stringify(data.field),
                    success: function (data) {
                        if (data.code == 10000) {
                            layer.msg('添加成功, 2秒后将返回首页', {'icon': 1});
                            returnManageIndex()
                        }
                        if (data.code == 10001) {
                            layer.open({
                                title: '添加失败'
                                , content: '项目名称已存在哒'
                            });
                            {#layer.msg('添加失败,', {"icon": 5})#}
                        }

                    }
                });
                {#
                layer.alert(JSON.stringify(data.field), {
                    title: '最终的提交信息'
                }) #}
                return false;
            });

        });
    </script>


{% endblock %}